<?php
namespace app\admin\controller;
use think\Db;
class Wxmenu extends Base
{	
    public function edit($id = 1){
        
        if( is_post() ){
            $id      = input('id');
            $content = input('content');
            
            #更新
            $d = json_decode( str_replace([" ","　","\t","\n","\r"], '', $content), true);
            $wx = \app\common\model\Wx::getObj();
            if( $wx->createMenu($d) ){
                Db::name('wx_menu')->update(['id'=>$id, 'content'=>$content]);
            }else{
                return com_error(['更新失败!']);
            }
            com_check(['suc'=>['msg'=>'更新成功！','js_action'=>'alert']]);
        }
        
        $info = Db::name('wx_menu')->find($id);
        $data = [
            'info' => $info,
        ];
        return view('', $data);    
    }
}